package com.qf.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsRoleMapper;
import com.qf.pojo.DtsRole;
import com.qf.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;


@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private DtsRoleMapper dtsRoleMapper;

    @Override
    public Set<String> queryByRoleIds(Integer[] roleIds) {

        QueryWrapper wrapper = new QueryWrapper();
        wrapper.in("id", Arrays.asList(roleIds));
        wrapper.eq("deleted", false);
        wrapper.eq("enabled", true);

        List<DtsRole> list = dtsRoleMapper.selectList(wrapper);
        HashSet<String> hashSet = new HashSet<>();
        for (DtsRole dtsRole : list) {
            hashSet.add(dtsRole.getName());
        }
        return hashSet;
    }
}
